#!/usr/bin/env ruby
require 'rubygems'
require 'xmpp4r/client'
require 'xmpp4r/roster'
require 'xmpp4r/version'

Jabber::debug = true

class Annei
	def connect
		begin
			jid = Jabber::JID::new('example@example.org/Bot')
			password = ''

			@connection = Jabber::Client::new(jid,true)
			@connection.on_exception { connect }

			@connection.connect
			@connection.auth(password)
			@connection.send(Jabber::Iq.new_rosterget)
			@connection.send(Jabber::Presence.new.set_show(:chat).set_status('Test'))

			my_version_helper = Jabber::Version::Helper.new(@connection)
			my_version_helper.add_version_callback { |iq|
				yield 'Cool client', '6.0', 'Cool OS'
			}
			
			@roster = Jabber::Roster::Helper.new @connection
			loop do
			end
		ensure
			@connection.close
		end
	end

	def set_status_message
		puts "Status message set"
		@connection.send(Jabber::Presence.new.set_show(:chat).set_status('Annei ready'))
	end
end

annei = Annei.new
annei.connect
